package com.xbongbong.saas.enums.business;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum SerialStatusEnum {
    // 在库
    IN_STOCK(0, "enum.serialStatusEnum.name.in_stock"),
    // 出库
    OUT_STOCK(1, "enum.serialStatusEnum.name.out_stock"),
    // 调整
    ADJUST(2, "enum.serialStatusEnum.name.adjust"),
    ;

    private final Integer code;
    private final String name;

    SerialStatusEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static SerialStatusEnum getByCode(Integer code) {
        for (SerialStatusEnum serialStatusEnum : SerialStatusEnum.values()) {
            if (Objects.equals(code, serialStatusEnum.getCode())) {
                return serialStatusEnum;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

    public static String getI18nValue(String value) {
        return I18nMessageUtil.getMessage(value);
    }
}
